package com.app.web.user.team;

import com.app.utils.base.j2se.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Description
 * Created by 王伟
 * Date create on 14:26 2019/11/19.
 */
@Service
public class TeamService {

    @Autowired
    private TeamInfoDao teamInfoDao;
    /**
     * 功能：获取直属和直属下级人数信息
     * @param mcode 推荐码
     * @return 直属和直属下级人数信息
     */
    public List<Map<String,Object>> getSubAndNextList(int mcode,String nickName, int pageNum){
        Map<String,Object> param = new HashMap<String,Object>(){{
            put("mcode",mcode);
            put("nickName",nickName);
            put("pageSize",(pageNum-1)*20);
            put("size",20);
        }};
        List<Map<String,Object>> mapList = teamInfoDao.getSubAndNextList(param);
        return mapList.stream().map(x->{
            x.put("registTime", Convert.objToStr(x.get("create_time")).substring(0,10));
            return x;
        }).collect(Collectors.toList());
    }
}
